package com.songlanyun.common.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 关于公益的常量及枚举类
 */
public class DonationConstant {

    /**
     * 优惠券状态 0待服务，1已捐，2未捐
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum DonationStatus implements IntegerEnum<Integer> {
        //已终止
        WAIT(0, "待服务"),
        YES(1, "已捐"),
        NO(2, "未捐"),
        ;
        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        DonationStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static DonationConstant.DonationStatus getByCode(int code) {
            for (DonationConstant.DonationStatus value : DonationConstant.DonationStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 消息类型
     */
    public static enum MsgType implements IntegerEnum<Integer> {
        /**
         * 0：捐赠消息
         * 1：购买消息
         */
        DONATE(0, "捐赠消息"),
        BUY(1, "购买消息"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        MsgType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static DonationConstant.MsgType getByCode(int code) {
            for (DonationConstant.MsgType value : DonationConstant.MsgType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 捐赠消息类型
     */
    public static enum DonateMsgType implements IntegerEnum<Integer> {
        /**
         * 捐赠消息类型
         * 0：官方捐赠
         * 1：公益捐赠
         * 2：公益捐款
         */
        OFFICIAL_DONATION(0, "官方捐赠"),
        CHARITABLE_DONATIONS(1, "公益捐赠"),
        PUBLIC_WELFARE_DONATION(2, "公益捐款");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        DonateMsgType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static DonationConstant.DonateMsgType getByCode(int code) {
            for (DonationConstant.DonateMsgType value : DonationConstant.DonateMsgType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 购买消息类型
     */
    public static enum BuyMsgType implements IntegerEnum<Integer> {
        /**
         * 0：普通商品
         * 1：免费领取
         */
        GENERAL_GOODS(0, "普通商品"),
        FREE_GOODS(1, "免费领取"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        BuyMsgType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static DonationConstant.BuyMsgType getByCode(int code) {
            for (DonationConstant.BuyMsgType value : DonationConstant.BuyMsgType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

//    /**
//     * 捐赠类型
//     */
//    public static enum DonateType implements IntegerEnum<Integer> {
//        /**
//         * 捐赠消息类型
//         * 0：官方捐赠
//         * 1：公益捐赠
//         * 2：公益捐款
//         */
//        OFFICIAL_DONATION(0, "官方捐赠"),
//        CHARITABLE_DONATIONS(1, "公益捐赠"),
//        PUBLIC_WELFARE_DONATION(2, "公益捐款");
//
//        @EnumValue
//        @JsonValue
//        private Integer code;
//
//        private String msg;
//
//        DonateType(Integer code, String msg) {
//            this.code = code;
//            this.msg = msg;
//        }
//
//        public void setCode(Integer code) {
//            this.code = code;
//        }
//
//        @Override
//        public String getMsg() {
//            return msg;
//        }
//
//        public void setMsg(String msg) {
//            this.msg = msg;
//        }
//
//        @Override
//        public Integer getCode() {
//            return code;
//        }
//
//        @JsonCreator
//        public static DonationConstant.DonateType getByCode(int code) {
//            for (DonationConstant.DonateType value : DonationConstant.DonateType.values()) {
//                if (Objects.equals(code, value.getCode())) {
//                    return value;
//                }
//            }
//            return null;
//        }
//    }

    /**
     * 公益类型
     */
    public static enum WelfareType implements IntegerEnum<Integer> {
        /**
         * 公益类型
         * 0：捐款
         * 1：捐物
         * 2：捐积分
         */
        DONATION(0, "捐款"),
        OFFERING(1, "捐物"),
        DONATE_POINTS(2, "捐积分"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        WelfareType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static DonationConstant.WelfareType getByCode(int code) {
            for (DonationConstant.WelfareType value : DonationConstant.WelfareType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

}
